home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LT_GetAttributes.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  7KB  |  333 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. LONG __stdargs
  10. LT_GetAttributes(LayoutHandle *Handle,LONG ID,...)
  11. {
  12.     va_list VarArgs;
  13.     LONG    Result;
  14.  
  15.     va_start(VarArgs,ID);
  16.     Result = LT_GetAttributesA(Handle,ID,(struct TagItem *)VarArgs);
  17.     va_end(VarArgs);
  18.  
  19.     return(Result);
  20. }
  21.  
  22.  
  23. /*****************************************************************************/
  24.  
  25.  
  26. LONG LIBENT
  27. LT_GetAttributesA(REG(a0) LayoutHandle *Handle,REG(d0) LONG ID,REG(a1) struct TagItem *TagList)
  28. {
  29.     if(Handle)
  30.     {
  31.         struct TagItem    *ThisTag;
  32.         ObjectNode    *Node = NULL;
  33.  
  34.         if(ThisTag = FindTagItem(LAPR_Gadget,TagList))
  35.             Node = ((struct Gadget *)ThisTag -> ti_Data) -> UserData;
  36.  
  37.         if(!Node)
  38.         {
  39.             if(ThisTag = FindTagItem(LAPR_Object,TagList))
  40.                 Node = (ObjectNode *)ThisTag -> ti_Data;
  41.         }
  42.  
  43.         if(!Node)
  44.             Node = LTP_FindNode(Handle -> TopGroup,ID);
  45.  
  46.         if(Node)
  47.         {
  48.             if(TagList)
  49.             {
  50.                 struct TagItem    *TagItem,
  51.                         *TempPtr = TagList;
  52.                 LONG        *Value;
  53.  
  54.                 while(TagItem = NextTagItem(&TempPtr))
  55.                 {
  56.                     Value = (LONG *)TagItem -> ti_Data;
  57.  
  58.                     switch(TagItem -> ti_Tag)
  59.                     {
  60.                         case LA_Left:
  61.  
  62.                             if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
  63.                                 *Value = Node -> Left + 4;
  64.                             else
  65.                                 *Value = Node -> Left;
  66.  
  67.                             break;
  68.  
  69.                         case LA_Top:
  70.  
  71.                             if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
  72.                                 *Value = Node -> Top + 2;
  73.                             else
  74.                                 *Value = Node -> Top;
  75.  
  76.                             break;
  77.  
  78.                         case LA_Width:
  79.  
  80.                             if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
  81.                                 *Value = Node -> Width - 8;
  82.                             else
  83.                                 *Value = Node -> Width;
  84.  
  85.                             break;
  86.  
  87.                         case LA_Height:
  88.  
  89.                             if(Node -> Type == FRAME_KIND && Node -> Special . Frame . DrawBox)
  90.                                 *Value = Node -> Height - 4;
  91.                             else
  92.                                 *Value = Node -> Height;
  93.  
  94.                             break;
  95.  
  96. #ifdef DO_BOOPSI_KIND
  97.                         case LABO_Object:
  98.  
  99.                             if(Node -> Type == BOOPSI_KIND)
  100.                                 *Value = (LONG)Node -> Host;
  101.                             else
  102.                                 *Value = NULL;
  103.  
  104.                             break;
  105. #endif    /* DO_BOOPSI_KIND */
  106.                         case LA_Chars:
  107.  
  108.                             *Value = Node -> Chars;
  109.                             break;
  110.  
  111.                         case LA_Lines:
  112.  
  113.                             *Value = Node -> Lines;
  114.                             break;
  115.  
  116.                         case LA_LabelLeft:
  117.  
  118.                             switch(Node -> LabelPlace)
  119.                             {
  120.                                 case PLACE_LEFT:
  121.  
  122.                                     *Value    = Node -> Left - (INTERWIDTH + Node -> LabelWidth);
  123.                                     break;
  124.  
  125.                                 case PLACE_RIGHT:
  126.  
  127.                                     *Value    = Node -> Left + Node -> Width + INTERWIDTH;
  128.                                     break;
  129.  
  130.                                 case PLACE_ABOVE:
  131.  
  132.                                     *Value    = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2;
  133.                                     break;
  134.  
  135.                                 case PLACE_BELOW:
  136.  
  137.                                     *Value    = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2;
  138.                                     break;
  139.  
  140.                                 case PLACE_IN:
  141.  
  142.                                     *Value    = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2;
  143.                                     break;
  144.                             }
  145.  
  146.                             break;
  147.  
  148.                         case LA_LabelTop:
  149.  
  150.                             switch(Node -> LabelPlace)
  151.                             {
  152.                                 case PLACE_LEFT:
  153.  
  154.                                     *Value    = Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2;
  155.                                     break;
  156.  
  157.                                 case PLACE_RIGHT:
  158.  
  159.                                     *Value    = Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2;
  160.                                     break;
  161.  
  162.                                 case PLACE_ABOVE:
  163.  
  164.                                     *Value    = Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT);
  165.                                     break;
  166.  
  167.                                 case PLACE_BELOW:
  168.  
  169.                                     *Value    = Node -> Top + Node -> Height + INTERHEIGHT;
  170.                                     break;
  171.  
  172.                                 case PLACE_IN:
  173.  
  174.                                     *Value    = Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2;
  175.                                     break;
  176.                             }
  177.  
  178.                             break;
  179.                     }
  180.                 }
  181.             }
  182.  
  183.             if(Node -> Host)
  184.             {
  185.                 struct Gadget *Gadget = Node -> Host;
  186.  
  187.                 switch(Node -> Type)
  188.                 {
  189.                     case CHECKBOX_KIND:
  190.                     case LISTVIEW_KIND:
  191.                     case MX_KIND:
  192.                     case CYCLE_KIND:
  193.                     case PALETTE_KIND:
  194.                     case SLIDER_KIND:
  195.                     case SCROLLER_KIND:
  196. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  197.                     case POPUP_KIND:
  198. #endif
  199. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  200.                     case TAB_KIND:
  201. #endif
  202. #ifdef DO_GAUGE_KIND
  203.                     case GAUGE_KIND:
  204. #endif
  205. #ifdef DO_TAPEDECK_KIND
  206.                     case TAPEDECK_KIND:
  207. #endif    /* DO_TAPEDECK_KIND */
  208.                         return(Node -> Current);
  209. #ifdef DO_BOOPSI_KIND
  210.                     case BOOPSI_KIND:
  211.                     {
  212.                         ULONG Storage;
  213.  
  214.                         if(GetAttr(Node -> Special . BOOPSI . TagCurrent,Node -> Host,&Storage))
  215.                             return((LONG)Storage);
  216.                         else
  217.                             return(NULL);
  218.                     }
  219. #endif    /* DO_BOOPSI_KIND */
  220.  
  221.                     case VERTICAL_KIND:
  222.                     case HORIZONTAL_KIND:
  223.  
  224.                         return((LONG)Node -> Special . Group . ActivePage);
  225.  
  226. #ifdef DO_FRACTION_KIND
  227.                     case FRACTION_KIND:
  228.                     {
  229.                         STRPTR String;
  230.  
  231.                         if(Gadget)
  232.                             String = ((struct StringInfo *)Gadget -> SpecialInfo) -> Buffer;
  233.                         else
  234.                             String = Node -> Special . String . String;
  235.  
  236.                         if(String)
  237.                         {
  238.                             FIXED Contents;
  239.  
  240.                             Contents = LT_String2Fixed(String);
  241.  
  242.                             if(Contents < Node -> Min)
  243.                                 Contents = Node -> Min;
  244.                             else
  245.                             {
  246.                                 if(Contents > Node -> Max)
  247.                                     Contents = Node -> Max;
  248.                             }
  249.  
  250.                             LT_SetAttributes(Handle,Gadget -> GadgetID,LAFC_Number,Contents,TAG_DONE);
  251.  
  252.                             return((LONG)Contents);
  253.                         }
  254.                     }
  255.                     break;
  256. #endif
  257.  
  258. #ifdef DO_LEVEL_KIND
  259.                     case LEVEL_KIND:
  260.  
  261.                         return(Node -> Special . Level . Level);
  262. #endif    /* DO_LEVEL_KIND */
  263.                     case STRING_KIND:
  264.  
  265.                         if(Gadget)
  266.                         {
  267.                             struct StringInfo *StringInfo;
  268.  
  269.                             StringInfo = (struct StringInfo *)Gadget -> SpecialInfo;
  270.  
  271.                             return((LONG)StringInfo -> Buffer);
  272.                         }
  273.                         else
  274.                         {
  275.                             STRPTR String = Node -> Special . String . String;
  276.  
  277.                             if(String)
  278.                                 return((LONG)String);
  279.                             else
  280.                                 return((LONG)"");
  281.                         }
  282.  
  283.                         break;
  284. #ifdef DO_PASSWORD_KIND
  285.                     case PASSWORD_KIND:
  286.  
  287.                         return((LONG)Node -> Special . String . Original);
  288.  
  289.                         break;
  290. #endif
  291.                     case INTEGER_KIND:
  292.  
  293.                         if(Gadget)
  294.                         {
  295.                             struct StringInfo    *StringInfo;
  296.                             LONG             Contents;
  297.  
  298.                             StringInfo = (struct StringInfo *)Gadget -> SpecialInfo;
  299.  
  300.                             Contents = StringInfo -> LongInt;
  301.  
  302.                             if(Contents < Node -> Min)
  303.                                 Contents = Node -> Min;
  304.                             else
  305.                             {
  306.                                 if(Contents > Node -> Max)
  307.                                     Contents = Node -> Max;
  308.                             }
  309.  
  310.                             LT_SetAttributes(Handle,Gadget -> GadgetID,
  311.                                 GTIN_Number,Contents,
  312.                             TAG_DONE);
  313.  
  314.                             return(Contents);
  315.                         }
  316.                         else
  317.                             return(Node -> Current);
  318.  
  319.                         break;
  320.  
  321.                     case GROUP_KIND:
  322.  
  323.                         return((LONG)Node -> Special . Group . ActivePage);
  324.                 }
  325.             }
  326.         }
  327.         else
  328.             return((LONG)Handle -> UserData);
  329.     }
  330.  
  331.     return(NULL);
  332. }
  333.